<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>lesson 21</title>
  <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
  <div id="root"></div>
</body>
<script>
  // 异步组件 异步执行某些组件的逻辑，叫做异步组件

  const app = Vue.createApp({

    data(){
      return {
        isShow: 'input-item'
      }
    },
    methods: {
      handClick(){

      },
    },

    template: `
      <div>
        <div-item/>
        <async-common-item/>
      </div>
    `
  });


  app.component('div-item', {
    template: `
      <div>hello word </div>
      `
  })

  app.component('async-common-item', Vue.defineAsyncComponent(()=>{
    return new Promise((resolve, reject)=>{
      setTimeout(()=>{
        resolve({
          template: `<div>我是一个异步组件</div>`
        })
      },3000)
    })
  }))



  const vm = app.mount('#root');
</script>
</html>